package kin.exception;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import kin.bean.system.MyException;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
class GlobalDefaultExceptionHandler {
   
	
	@ResponseBody
    @ExceptionHandler(value = {Exception.class})
    public MyException defaultErrorHandler(HttpServletRequest request, Exception ex) {
		//request.setAttribute("myex", ex);
        MyException exception=new MyException();
		if (ex instanceof IOException) {
			exception.setMsg("IOException");
			exception.setExptionType("exception");
			exception.setUrl("/aaa");
			exception.setRedirect(false);
		
		} else if (ex instanceof NullPointerException) {
			
		} else if (ex instanceof NumberFormatException) {
			
		} else {
			
		}
		return exception;
    }
}
